import 'package:flutter/material.dart';

import '../../databases/book.dart';
import '../../widgets/common_image.dart';

class NovelDetailHeader extends StatelessWidget {
  const NovelDetailHeader({Key? key}) : super(key: key);

  Widget buildScore() {
    List<Widget> children = [
      Text('评分：6分  ', style: TextStyle(fontSize: 14, color: Color(0xfff8e71c)))
    ];

    var star = 6;

    for (var i = 0; i < 5; i++) {
      if (star < i) {
        break;
      }
      var img;
      if (star <= i + 0.5) {
        img = Image.asset('static/img/detail_star_half.png');
      } else {
        img = Image.asset('static/img/detail_star.png');
      }
      children.add(img);
      children.add(SizedBox(width: 5));
    }
    return Row(
      children: children,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 40.0),
      child: Row(
        children: [
          Container(
              width: 100.0,
              height: 130.0,
              margin: EdgeInsets.only(right: 10.0),
              child: CommonImage(bookDetailData.bookImgUrl!)),
          Expanded(
            child: Container(
              height: 120,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text('${bookDetailData.title!}'),
                  Text('作者：${bookDetailData.subTitle!}'),
                  Text('类型：${bookDetailData.title!}'),
                  Text('状态：${bookDetailData.title!}'),
                  buildScore(),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}
